package br.com.investmenttracker.controller;

import javax.persistence.EntityManager;

import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.Validator;
import br.com.investmenttracker.dao.ContaDao;
import br.com.investmenttracker.modelo.Conta;
import br.com.investmenttracker.modelo.Usuario;

@Resource
public class ContaController {
	private Result result;
	private Validator validator;
	private EntityManager em;
	private ContaDao dao;
	
	public ContaController(EntityManager em,Result result, Validator validator, ContaDao dao){
		this.result = result;
		this.validator = validator;
		this.em = em;
		this.dao = dao;
	}
	
	public void form(){
		
	}
	
	public void listar(){
		
	}
	
	public void cadastrar(Conta conta){
		Usuario usuario = em.find(Usuario.class, Long.parseLong("2"));
		conta.setUsuario(usuario);
		em.persist(conta);
		result.redirectTo(this).listar();
	}
	
}
